package com.realgodo.site.web.user.space;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;

import com.realgodo.site.service.UserManager;
import com.realgodo.site.web.user.UserDefaultController;

@Scope("prototype")
@Results( {
		@Result(name = "user_index", type = "redirect", location = "${base}/user/index/"),
		@Result(name = "error", type = "redirect", location = "${base}/login") })
public class HeadController extends UserDefaultController {

	private static final long serialVersionUID = 7313931705943204222L;

	@Autowired
	private UserManager userManager;

	private String headPath;

	public String index() {
		if (null != getHeadPath() && !"".equals(getHeadPath())) {
			
			super.getSpace().setUser(this.userManager.saveUserHead(headPath, super.getUser()
					.getId()));
		}
		return "user_index";
	}

	public String getHeadPath() {
		return headPath;
	}

	public void setHeadPath(String headPath) {
		this.headPath = headPath;
	}

}
